﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using LayuiDemo.Models;


namespace LayuiDemo.ViewModels.BlogVMs
{
	public partial class BlogListVM : BasePagedListVM<Blog_View, BlogSearcher>
	{

		protected override List<GridAction> InitGridAction()
		{
			return new List<GridAction>
			{
				this.MakeAction("Blog","TestIds","TestIDs","TestIds",GridActionParameterTypesEnum.NoId,"",800),
				this.MakeStandardAction("Blog", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"", dialogWidth: 800),
				this.MakeAction("Blog","js","js","js",GridActionParameterTypesEnum.SingleId, dialogWidth: 800).SetOnClickScript("test1").SetShowInRow(),
				this.MakeStandardAction("Blog", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "", dialogWidth: 800),
				this.MakeStandardAction("Blog", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "", dialogWidth: 800),
				this.MakeStandardAction("Blog", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "", dialogWidth: 800),

				this.MakeStandardAction("Blog", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "", dialogWidth: 800),
				this.MakeStandardAction("Blog", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], ""),

				this.MakeActionsGroup("下拉按钮组",new List<GridAction>{
								this.MakeStandardAction("Blog", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "", dialogWidth: 800),
								this.MakeStandardAction("Blog", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "", dialogWidth: 800),



				}),
			};
		}


		protected override IEnumerable<IGridColumn<Blog_View>> InitGridHeader()
		{
			return new List<GridColumn<Blog_View>>{
				this.MakeGridHeader(x => x.Name).SetForeGroundFunc(e=>"green"),
				this.MakeGridHeader(x => x.ButtonSize).SetEditType(EditTypeEnum.Text),
				this.MakeGridHeader(x => x.CreateTime).SetBackGroundFunc(e=>"red"),
				this.MakeGridHeader(x => x.Url).SetEvent("rea"),
				this.MakeGridHeader(x => x.CreateBy).SetShowTotal(),
				this.MakeGridHeaderAction(width: 200)
			};
		}

		public override IOrderedQueryable<Blog_View> GetSearchQuery()
		{
			var query = DC.Set<Blog>()
				.CheckContain(Searcher.Url, x => x.Url)
				.CheckContain(Searcher.Name, x => x.Name)
				.Select(x => new Blog_View
				{
					ID = x.ID,
					Url = x.Url,
					CreateBy = x.CreateBy,
					Name = x.Name,
					ButtonSize = x.ButtonSize,
					CreateTime = x.CreateTime
				})
				.OrderBy(x => x.ID);
			return query;
		}

	}

	public class Blog_View : Blog
	{

	}
}
